const host = "http://localhost:3004/"
// animal/selData
// 热门列表
export const selData = (type) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "animal/selData",
			method: "POST",
			data: {
				type
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// animal/selList
// 分类
export const selList = () => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "animal/selList",
			method: "GET",
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// animal/selDetail
// 动物详情
export const selDetail = (id) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "animal/selDetail",
			method: "post",
			data: {
				id
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// animal/selHotList
// 搜索热门列表
export const selHotList = () => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "animal/selHotList",
			method: "POST",
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
};

// animal/getList
// 搜索返回列表
export const getList = (pet_name) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "animal/getList",
			method: "POST",
			data: {
				pet_name
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
};

// animal/kindList
// 分类列表
export const kindList = (pet_type, num) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "animal/kindList",
			method: "POST",
			data: {
				pet_type,
				num
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/login
// 登录
export const login = (acc, password) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/login",
			method: "POST",
			data: {
				acc,
				password
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/register
// 注册
export const register = (nick_name, acc, password) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/register",
			method: "POST",
			data: {
				nick_name,
				acc,
				password
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/userDesc
export const userDesc = (id) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/userDesc",
			method: "POST",
			data: {
				id
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/changeUserMsg
// 用户修改信息
export const changeUserMsg = (id, nick_name, password, sig) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/changeUserMsg",
			method: "POST",
			data: {
				id,
				nick_name,
				password,
				sig
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/addWeb
// 用户浏览记录
export const addWeb = (uid, did) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/addWeb",
			method: "POST",
			data: {
				uid,
				did
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}

// user/userWebList
// 用户浏览列表
export const userWebList = (uid) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/userWebList",
			method: "POST",
			data: {
				uid
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/addCol
// 用户收藏记录
export const addCol = (uid, did) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/addCol",
			method: "POST",
			data: {
				uid,
				did
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/judgmentUserCol
// 判断是否收藏
export const judgmentUserCol = (uid, did) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/judgmentUserCol",
			method: "POST",
			data: {
				uid,
				did
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}
// user/userColList
// 用户收藏列表
export const userColList = (uid) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + "user/userColList",
			method: "POST",
			data: {
				uid
			},
			success(data) {
				resolve({
					code: 200,
					data: data.data
				})
			}
		})
	})
}